{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pandas.read_csv('../data/gapminder.tsv', sep='\\t')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>pop</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1952</td>\n",
       "      <td>28.801</td>\n",
       "      <td>8425333</td>\n",
       "      <td>779.445314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1957</td>\n",
       "      <td>30.332</td>\n",
       "      <td>9240934</td>\n",
       "      <td>820.853030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1962</td>\n",
       "      <td>31.997</td>\n",
       "      <td>10267083</td>\n",
       "      <td>853.100710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1967</td>\n",
       "      <td>34.020</td>\n",
       "      <td>11537966</td>\n",
       "      <td>836.197138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1972</td>\n",
       "      <td>36.088</td>\n",
       "      <td>13079460</td>\n",
       "      <td>739.981106</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country continent  year  lifeExp       pop   gdpPercap\n",
       "0  Afghanistan      Asia  1952   28.801   8425333  779.445314\n",
       "1  Afghanistan      Asia  1957   30.332   9240934  820.853030\n",
       "2  Afghanistan      Asia  1962   31.997  10267083  853.100710\n",
       "3  Afghanistan      Asia  1967   34.020  11537966  836.197138\n",
       "4  Afghanistan      Asia  1972   36.088  13079460  739.981106"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv('../data/gapminder.tsv', sep='\\t')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>pop</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1952</td>\n",
       "      <td>28.801</td>\n",
       "      <td>8425333</td>\n",
       "      <td>779.445314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1957</td>\n",
       "      <td>30.332</td>\n",
       "      <td>9240934</td>\n",
       "      <td>820.853030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1962</td>\n",
       "      <td>31.997</td>\n",
       "      <td>10267083</td>\n",
       "      <td>853.100710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1967</td>\n",
       "      <td>34.020</td>\n",
       "      <td>11537966</td>\n",
       "      <td>836.197138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1972</td>\n",
       "      <td>36.088</td>\n",
       "      <td>13079460</td>\n",
       "      <td>739.981106</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country continent  year  lifeExp       pop   gdpPercap\n",
       "0  Afghanistan      Asia  1952   28.801   8425333  779.445314\n",
       "1  Afghanistan      Asia  1957   30.332   9240934  820.853030\n",
       "2  Afghanistan      Asia  1962   31.997  10267083  853.100710\n",
       "3  Afghanistan      Asia  1967   34.020  11537966  836.197138\n",
       "4  Afghanistan      Asia  1972   36.088  13079460  739.981106"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1704, 6)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'tuple' object is not callable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-9-72b44c061663>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: 'tuple' object is not callable"
     ]
    }
   ],
   "source": [
    "df.shape()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['country', 'continent', 'year', 'lifeExp', 'pop', 'gdpPercap'], dtype='object')"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=1704, step=1)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([['Afghanistan', 'Asia', 1952, 28.801, 8425333, 779.4453145],\n",
       "       ['Afghanistan', 'Asia', 1957, 30.331999999999997, 9240934,\n",
       "        820.8530296],\n",
       "       ['Afghanistan', 'Asia', 1962, 31.997, 10267083, 853.1007099999999],\n",
       "       ..., \n",
       "       ['Zimbabwe', 'Africa', 1997, 46.809, 11404948, 792.4499602999999],\n",
       "       ['Zimbabwe', 'Africa', 2002, 39.989000000000004, 11926563,\n",
       "        672.0386227000001],\n",
       "       ['Zimbabwe', 'Africa', 2007, 43.486999999999995, 12311143,\n",
       "        469.70929810000007]], dtype=object)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "country       object\n",
       "continent     object\n",
       "year           int64\n",
       "lifeExp      float64\n",
       "pop            int64\n",
       "gdpPercap    float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1704 entries, 0 to 1703\n",
      "Data columns (total 6 columns):\n",
      "country      1704 non-null object\n",
      "continent    1704 non-null object\n",
      "year         1704 non-null int64\n",
      "lifeExp      1704 non-null float64\n",
      "pop          1704 non-null int64\n",
      "gdpPercap    1704 non-null float64\n",
      "dtypes: float64(2), int64(2), object(2)\n",
      "memory usage: 80.0+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Subsetting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "country_df = df['country']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    Afghanistan\n",
       "1    Afghanistan\n",
       "2    Afghanistan\n",
       "3    Afghanistan\n",
       "4    Afghanistan\n",
       "Name: country, dtype: object"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "country_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1699    Zimbabwe\n",
       "1700    Zimbabwe\n",
       "1701    Zimbabwe\n",
       "1702    Zimbabwe\n",
       "1703    Zimbabwe\n",
       "Name: country, dtype: object"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "country_df.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(country_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "subset = df[['country', 'continent', 'year']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1952</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1957</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1962</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1967</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1972</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country continent  year\n",
       "0  Afghanistan      Asia  1952\n",
       "1  Afghanistan      Asia  1957\n",
       "2  Afghanistan      Asia  1962\n",
       "3  Afghanistan      Asia  1967\n",
       "4  Afghanistan      Asia  1972"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0.20.3'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pandas.__version__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'[0 1] not in index'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-22-1b57588e7b00>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   1956\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mSeries\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mIndex\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1957\u001b[0m             \u001b[1;31m# either boolean or fancy integer index\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1958\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_array\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1959\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mDataFrame\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1960\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_frame\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m_getitem_array\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   2000\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtake\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconvert\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2001\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2002\u001b[1;33m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_convert_to_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2003\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtake\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconvert\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2004\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_convert_to_indexer\u001b[1;34m(self, obj, axis, is_setter)\u001b[0m\n\u001b[0;32m   1229\u001b[0m                 \u001b[0mmask\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcheck\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1230\u001b[0m                 \u001b[1;32mif\u001b[0m \u001b[0mmask\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0many\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1231\u001b[1;33m                     \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'%s not in index'\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0mobjarr\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mmask\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1232\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1233\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0m_values_from_object\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '[0 1] not in index'"
     ]
    }
   ],
   "source": [
    "df[[0, 1]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>pop</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1952</td>\n",
       "      <td>28.801</td>\n",
       "      <td>8425333</td>\n",
       "      <td>779.445314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1957</td>\n",
       "      <td>30.332</td>\n",
       "      <td>9240934</td>\n",
       "      <td>820.853030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1962</td>\n",
       "      <td>31.997</td>\n",
       "      <td>10267083</td>\n",
       "      <td>853.100710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1967</td>\n",
       "      <td>34.020</td>\n",
       "      <td>11537966</td>\n",
       "      <td>836.197138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1972</td>\n",
       "      <td>36.088</td>\n",
       "      <td>13079460</td>\n",
       "      <td>739.981106</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country continent  year  lifeExp       pop   gdpPercap\n",
       "0  Afghanistan      Asia  1952   28.801   8425333  779.445314\n",
       "1  Afghanistan      Asia  1957   30.332   9240934  820.853030\n",
       "2  Afghanistan      Asia  1962   31.997  10267083  853.100710\n",
       "3  Afghanistan      Asia  1967   34.020  11537966  836.197138\n",
       "4  Afghanistan      Asia  1972   36.088  13079460  739.981106"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "country      Afghanistan\n",
       "continent           Asia\n",
       "year                1952\n",
       "lifeExp           28.801\n",
       "pop              8425333\n",
       "gdpPercap        779.445\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>pop</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1952</td>\n",
       "      <td>28.801</td>\n",
       "      <td>8425333</td>\n",
       "      <td>779.445314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>Bangladesh</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1967</td>\n",
       "      <td>43.453</td>\n",
       "      <td>62821884</td>\n",
       "      <td>721.186086</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        country continent  year  lifeExp       pop   gdpPercap\n",
       "0   Afghanistan      Asia  1952   28.801   8425333  779.445314\n",
       "99   Bangladesh      Asia  1967   43.453  62821884  721.186086"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[[0, 99]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'the label [-1] is not in the [index]'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_has_valid_type\u001b[1;34m(self, key, axis)\u001b[0m\n\u001b[0;32m   1433\u001b[0m                 \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcontains\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1434\u001b[1;33m                     \u001b[0merror\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1435\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36merror\u001b[1;34m()\u001b[0m\n\u001b[0;32m   1428\u001b[0m                 raise KeyError(\"the label [%s] is not in the [%s]\" %\n\u001b[1;32m-> 1429\u001b[1;33m                                (key, self.obj._get_axis_name(axis)))\n\u001b[0m\u001b[0;32m   1430\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: 'the label [-1] is not in the [index]'",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-26-c88d0e464df6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   1326\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1327\u001b[0m             \u001b[0mkey\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_apply_if_callable\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1328\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_axis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1329\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1330\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m_is_scalar_access\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_getitem_axis\u001b[1;34m(self, key, axis)\u001b[0m\n\u001b[0;32m   1549\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1550\u001b[0m         \u001b[1;31m# fall thru to straight lookup\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1551\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_has_valid_type\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1552\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_label\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1553\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_has_valid_type\u001b[1;34m(self, key, axis)\u001b[0m\n\u001b[0;32m   1440\u001b[0m                 \u001b[1;32mraise\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1441\u001b[0m             \u001b[1;32mexcept\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1442\u001b[1;33m                 \u001b[0merror\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1443\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1444\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36merror\u001b[1;34m()\u001b[0m\n\u001b[0;32m   1427\u001b[0m                                     \"key\")\n\u001b[0;32m   1428\u001b[0m                 raise KeyError(\"the label [%s] is not in the [%s]\" %\n\u001b[1;32m-> 1429\u001b[1;33m                                (key, self.obj._get_axis_name(axis)))\n\u001b[0m\u001b[0;32m   1430\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1431\u001b[0m             \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: 'the label [-1] is not in the [index]'"
     ]
    }
   ],
   "source": [
    "df.loc[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "country      Afghanistan\n",
       "continent           Asia\n",
       "year                1952\n",
       "lifeExp           28.801\n",
       "pop              8425333\n",
       "gdpPercap        779.445\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>pop</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1952</td>\n",
       "      <td>28.801</td>\n",
       "      <td>8425333</td>\n",
       "      <td>779.445314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>Bangladesh</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1967</td>\n",
       "      <td>43.453</td>\n",
       "      <td>62821884</td>\n",
       "      <td>721.186086</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        country continent  year  lifeExp       pop   gdpPercap\n",
       "0   Afghanistan      Asia  1952   28.801   8425333  779.445314\n",
       "99   Bangladesh      Asia  1967   43.453  62821884  721.186086"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[[0, 99]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "country      Zimbabwe\n",
       "continent      Africa\n",
       "year             2007\n",
       "lifeExp        43.487\n",
       "pop          12311143\n",
       "gdpPercap     469.709\n",
       "Name: 1703, dtype: object"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "country      Afghanistan\n",
       "continent           Asia\n",
       "year                1952\n",
       "lifeExp           28.801\n",
       "pop              8425333\n",
       "gdpPercap        779.445\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.ix[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "subset = df.loc[:, ['year', 'pop']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1952</td>\n",
       "      <td>8425333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1957</td>\n",
       "      <td>9240934</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1962</td>\n",
       "      <td>10267083</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1967</td>\n",
       "      <td>11537966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1972</td>\n",
       "      <td>13079460</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   year       pop\n",
       "0  1952   8425333\n",
       "1  1957   9240934\n",
       "2  1962  10267083\n",
       "3  1967  11537966\n",
       "4  1972  13079460"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   year       pop\n",
      "0  1952   8425333\n",
      "1  1957   9240934\n",
      "2  1962  10267083\n",
      "3  1967  11537966\n",
      "4  1972  13079460\n"
     ]
    }
   ],
   "source": [
    "subset = df.iloc[:, [2, 4]]\n",
    "print(subset.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>pop</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1699</th>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>Africa</td>\n",
       "      <td>1987</td>\n",
       "      <td>62.351</td>\n",
       "      <td>9216418</td>\n",
       "      <td>706.157306</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1701</th>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>Africa</td>\n",
       "      <td>1997</td>\n",
       "      <td>46.809</td>\n",
       "      <td>11404948</td>\n",
       "      <td>792.449960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1703</th>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>Africa</td>\n",
       "      <td>2007</td>\n",
       "      <td>43.487</td>\n",
       "      <td>12311143</td>\n",
       "      <td>469.709298</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country continent  year  lifeExp       pop   gdpPercap\n",
       "1699  Zimbabwe    Africa  1987   62.351   9216418  706.157306\n",
       "1701  Zimbabwe    Africa  1997   46.809  11404948  792.449960\n",
       "1703  Zimbabwe    Africa  2007   43.487  12311143  469.709298"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subset = df.iloc[-5::2, :]\n",
    "subset.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# grouped calculations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>continent</th>\n",
       "      <th>year</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>pop</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1952</td>\n",
       "      <td>28.801</td>\n",
       "      <td>8425333</td>\n",
       "      <td>779.445314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1957</td>\n",
       "      <td>30.332</td>\n",
       "      <td>9240934</td>\n",
       "      <td>820.853030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1962</td>\n",
       "      <td>31.997</td>\n",
       "      <td>10267083</td>\n",
       "      <td>853.100710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1967</td>\n",
       "      <td>34.020</td>\n",
       "      <td>11537966</td>\n",
       "      <td>836.197138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Asia</td>\n",
       "      <td>1972</td>\n",
       "      <td>36.088</td>\n",
       "      <td>13079460</td>\n",
       "      <td>739.981106</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country continent  year  lifeExp       pop   gdpPercap\n",
       "0  Afghanistan      Asia  1952   28.801   8425333  779.445314\n",
       "1  Afghanistan      Asia  1957   30.332   9240934  820.853030\n",
       "2  Afghanistan      Asia  1962   31.997  10267083  853.100710\n",
       "3  Afghanistan      Asia  1967   34.020  11537966  836.197138\n",
       "4  Afghanistan      Asia  1972   36.088  13079460  739.981106"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "year\n",
       "1952    49.057620\n",
       "1957    51.507401\n",
       "1962    53.609249\n",
       "1967    55.678290\n",
       "1972    57.647386\n",
       "1977    59.570157\n",
       "1982    61.533197\n",
       "1987    63.212613\n",
       "1992    64.160338\n",
       "1997    65.014676\n",
       "2002    65.694923\n",
       "2007    67.007423\n",
       "Name: lifeExp, dtype: float64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby('year')['lifeExp'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>year</th>\n",
       "      <th>continent</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1952</th>\n",
       "      <th>Africa</th>\n",
       "      <td>39.135500</td>\n",
       "      <td>1252.572466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>53.279840</td>\n",
       "      <td>4079.062552</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>46.314394</td>\n",
       "      <td>5195.484004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>64.408500</td>\n",
       "      <td>5661.057435</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>69.255000</td>\n",
       "      <td>10298.085650</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1957</th>\n",
       "      <th>Africa</th>\n",
       "      <td>41.266346</td>\n",
       "      <td>1385.236062</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>55.960280</td>\n",
       "      <td>4616.043733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>49.318544</td>\n",
       "      <td>5787.732940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>66.703067</td>\n",
       "      <td>6963.012816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>70.295000</td>\n",
       "      <td>11598.522455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1962</th>\n",
       "      <th>Africa</th>\n",
       "      <td>43.319442</td>\n",
       "      <td>1598.078825</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>58.398760</td>\n",
       "      <td>4901.541870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>51.563223</td>\n",
       "      <td>5729.369625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>68.539233</td>\n",
       "      <td>8365.486814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>71.085000</td>\n",
       "      <td>12696.452430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1967</th>\n",
       "      <th>Africa</th>\n",
       "      <td>45.334538</td>\n",
       "      <td>2050.363801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>60.410920</td>\n",
       "      <td>5668.253496</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>54.663640</td>\n",
       "      <td>5971.173374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>69.737600</td>\n",
       "      <td>10143.823757</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>71.310000</td>\n",
       "      <td>14495.021790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1972</th>\n",
       "      <th>Africa</th>\n",
       "      <td>47.450942</td>\n",
       "      <td>2339.615674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>62.394920</td>\n",
       "      <td>6491.334139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>57.319269</td>\n",
       "      <td>8187.468699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>70.775033</td>\n",
       "      <td>12479.575246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>71.910000</td>\n",
       "      <td>16417.333380</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1977</th>\n",
       "      <th>Africa</th>\n",
       "      <td>49.580423</td>\n",
       "      <td>2585.938508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>64.391560</td>\n",
       "      <td>7352.007126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>59.610556</td>\n",
       "      <td>7791.314020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>71.937767</td>\n",
       "      <td>14283.979110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>72.855000</td>\n",
       "      <td>17283.957605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1982</th>\n",
       "      <th>Africa</th>\n",
       "      <td>51.592865</td>\n",
       "      <td>2481.592960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>66.228840</td>\n",
       "      <td>7506.737088</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>62.617939</td>\n",
       "      <td>7434.135157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>72.806400</td>\n",
       "      <td>15617.896551</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>74.290000</td>\n",
       "      <td>18554.709840</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1987</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.344788</td>\n",
       "      <td>2282.668991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>68.090720</td>\n",
       "      <td>7793.400261</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>64.851182</td>\n",
       "      <td>7608.226508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>73.642167</td>\n",
       "      <td>17214.310727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>75.320000</td>\n",
       "      <td>20448.040160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1992</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.629577</td>\n",
       "      <td>2281.810333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>69.568360</td>\n",
       "      <td>8044.934406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>66.537212</td>\n",
       "      <td>8639.690248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>74.440100</td>\n",
       "      <td>17061.568084</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>76.945000</td>\n",
       "      <td>20894.045885</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1997</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.598269</td>\n",
       "      <td>2378.759555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>71.150480</td>\n",
       "      <td>8889.300863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>68.020515</td>\n",
       "      <td>9834.093295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>75.505167</td>\n",
       "      <td>19076.781802</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>78.190000</td>\n",
       "      <td>24024.175170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2002</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.325231</td>\n",
       "      <td>2599.385159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>72.422040</td>\n",
       "      <td>9287.677107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>69.233879</td>\n",
       "      <td>10174.090397</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>76.700600</td>\n",
       "      <td>21711.732422</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>79.740000</td>\n",
       "      <td>26938.778040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2007</th>\n",
       "      <th>Africa</th>\n",
       "      <td>54.806038</td>\n",
       "      <td>3089.032605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>73.608120</td>\n",
       "      <td>11003.031625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>70.728485</td>\n",
       "      <td>12473.026870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>77.648600</td>\n",
       "      <td>25054.481636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>80.719500</td>\n",
       "      <td>29810.188275</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  lifeExp     gdpPercap\n",
       "year continent                         \n",
       "1952 Africa     39.135500   1252.572466\n",
       "     Americas   53.279840   4079.062552\n",
       "     Asia       46.314394   5195.484004\n",
       "     Europe     64.408500   5661.057435\n",
       "     Oceania    69.255000  10298.085650\n",
       "1957 Africa     41.266346   1385.236062\n",
       "     Americas   55.960280   4616.043733\n",
       "     Asia       49.318544   5787.732940\n",
       "     Europe     66.703067   6963.012816\n",
       "     Oceania    70.295000  11598.522455\n",
       "1962 Africa     43.319442   1598.078825\n",
       "     Americas   58.398760   4901.541870\n",
       "     Asia       51.563223   5729.369625\n",
       "     Europe     68.539233   8365.486814\n",
       "     Oceania    71.085000  12696.452430\n",
       "1967 Africa     45.334538   2050.363801\n",
       "     Americas   60.410920   5668.253496\n",
       "     Asia       54.663640   5971.173374\n",
       "     Europe     69.737600  10143.823757\n",
       "     Oceania    71.310000  14495.021790\n",
       "1972 Africa     47.450942   2339.615674\n",
       "     Americas   62.394920   6491.334139\n",
       "     Asia       57.319269   8187.468699\n",
       "     Europe     70.775033  12479.575246\n",
       "     Oceania    71.910000  16417.333380\n",
       "1977 Africa     49.580423   2585.938508\n",
       "     Americas   64.391560   7352.007126\n",
       "     Asia       59.610556   7791.314020\n",
       "     Europe     71.937767  14283.979110\n",
       "     Oceania    72.855000  17283.957605\n",
       "1982 Africa     51.592865   2481.592960\n",
       "     Americas   66.228840   7506.737088\n",
       "     Asia       62.617939   7434.135157\n",
       "     Europe     72.806400  15617.896551\n",
       "     Oceania    74.290000  18554.709840\n",
       "1987 Africa     53.344788   2282.668991\n",
       "     Americas   68.090720   7793.400261\n",
       "     Asia       64.851182   7608.226508\n",
       "     Europe     73.642167  17214.310727\n",
       "     Oceania    75.320000  20448.040160\n",
       "1992 Africa     53.629577   2281.810333\n",
       "     Americas   69.568360   8044.934406\n",
       "     Asia       66.537212   8639.690248\n",
       "     Europe     74.440100  17061.568084\n",
       "     Oceania    76.945000  20894.045885\n",
       "1997 Africa     53.598269   2378.759555\n",
       "     Americas   71.150480   8889.300863\n",
       "     Asia       68.020515   9834.093295\n",
       "     Europe     75.505167  19076.781802\n",
       "     Oceania    78.190000  24024.175170\n",
       "2002 Africa     53.325231   2599.385159\n",
       "     Americas   72.422040   9287.677107\n",
       "     Asia       69.233879  10174.090397\n",
       "     Europe     76.700600  21711.732422\n",
       "     Oceania    79.740000  26938.778040\n",
       "2007 Africa     54.806038   3089.032605\n",
       "     Americas   73.608120  11003.031625\n",
       "     Asia       70.728485  12473.026870\n",
       "     Europe     77.648600  25054.481636\n",
       "     Oceania    80.719500  29810.188275"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['year', 'continent'])[['lifeExp', 'gdpPercap']].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>year</th>\n",
       "      <th>continent</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1952</th>\n",
       "      <th>Africa</th>\n",
       "      <td>39.135500</td>\n",
       "      <td>1252.572466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>53.279840</td>\n",
       "      <td>4079.062552</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>46.314394</td>\n",
       "      <td>5195.484004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>64.408500</td>\n",
       "      <td>5661.057435</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>69.255000</td>\n",
       "      <td>10298.085650</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1957</th>\n",
       "      <th>Africa</th>\n",
       "      <td>41.266346</td>\n",
       "      <td>1385.236062</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>55.960280</td>\n",
       "      <td>4616.043733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>49.318544</td>\n",
       "      <td>5787.732940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>66.703067</td>\n",
       "      <td>6963.012816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>70.295000</td>\n",
       "      <td>11598.522455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1962</th>\n",
       "      <th>Africa</th>\n",
       "      <td>43.319442</td>\n",
       "      <td>1598.078825</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>58.398760</td>\n",
       "      <td>4901.541870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>51.563223</td>\n",
       "      <td>5729.369625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>68.539233</td>\n",
       "      <td>8365.486814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>71.085000</td>\n",
       "      <td>12696.452430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1967</th>\n",
       "      <th>Africa</th>\n",
       "      <td>45.334538</td>\n",
       "      <td>2050.363801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>60.410920</td>\n",
       "      <td>5668.253496</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>54.663640</td>\n",
       "      <td>5971.173374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>69.737600</td>\n",
       "      <td>10143.823757</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>71.310000</td>\n",
       "      <td>14495.021790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1972</th>\n",
       "      <th>Africa</th>\n",
       "      <td>47.450942</td>\n",
       "      <td>2339.615674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>62.394920</td>\n",
       "      <td>6491.334139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>57.319269</td>\n",
       "      <td>8187.468699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>70.775033</td>\n",
       "      <td>12479.575246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>71.910000</td>\n",
       "      <td>16417.333380</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1977</th>\n",
       "      <th>Africa</th>\n",
       "      <td>49.580423</td>\n",
       "      <td>2585.938508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>64.391560</td>\n",
       "      <td>7352.007126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>59.610556</td>\n",
       "      <td>7791.314020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>71.937767</td>\n",
       "      <td>14283.979110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>72.855000</td>\n",
       "      <td>17283.957605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1982</th>\n",
       "      <th>Africa</th>\n",
       "      <td>51.592865</td>\n",
       "      <td>2481.592960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>66.228840</td>\n",
       "      <td>7506.737088</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>62.617939</td>\n",
       "      <td>7434.135157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>72.806400</td>\n",
       "      <td>15617.896551</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>74.290000</td>\n",
       "      <td>18554.709840</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1987</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.344788</td>\n",
       "      <td>2282.668991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>68.090720</td>\n",
       "      <td>7793.400261</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>64.851182</td>\n",
       "      <td>7608.226508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>73.642167</td>\n",
       "      <td>17214.310727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>75.320000</td>\n",
       "      <td>20448.040160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1992</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.629577</td>\n",
       "      <td>2281.810333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>69.568360</td>\n",
       "      <td>8044.934406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>66.537212</td>\n",
       "      <td>8639.690248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>74.440100</td>\n",
       "      <td>17061.568084</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>76.945000</td>\n",
       "      <td>20894.045885</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">1997</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.598269</td>\n",
       "      <td>2378.759555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>71.150480</td>\n",
       "      <td>8889.300863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>68.020515</td>\n",
       "      <td>9834.093295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>75.505167</td>\n",
       "      <td>19076.781802</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>78.190000</td>\n",
       "      <td>24024.175170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2002</th>\n",
       "      <th>Africa</th>\n",
       "      <td>53.325231</td>\n",
       "      <td>2599.385159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>72.422040</td>\n",
       "      <td>9287.677107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>69.233879</td>\n",
       "      <td>10174.090397</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>76.700600</td>\n",
       "      <td>21711.732422</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>79.740000</td>\n",
       "      <td>26938.778040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2007</th>\n",
       "      <th>Africa</th>\n",
       "      <td>54.806038</td>\n",
       "      <td>3089.032605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Americas</th>\n",
       "      <td>73.608120</td>\n",
       "      <td>11003.031625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asia</th>\n",
       "      <td>70.728485</td>\n",
       "      <td>12473.026870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Europe</th>\n",
       "      <td>77.648600</td>\n",
       "      <td>25054.481636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oceania</th>\n",
       "      <td>80.719500</td>\n",
       "      <td>29810.188275</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  lifeExp     gdpPercap\n",
       "year continent                         \n",
       "1952 Africa     39.135500   1252.572466\n",
       "     Americas   53.279840   4079.062552\n",
       "     Asia       46.314394   5195.484004\n",
       "     Europe     64.408500   5661.057435\n",
       "     Oceania    69.255000  10298.085650\n",
       "1957 Africa     41.266346   1385.236062\n",
       "     Americas   55.960280   4616.043733\n",
       "     Asia       49.318544   5787.732940\n",
       "     Europe     66.703067   6963.012816\n",
       "     Oceania    70.295000  11598.522455\n",
       "1962 Africa     43.319442   1598.078825\n",
       "     Americas   58.398760   4901.541870\n",
       "     Asia       51.563223   5729.369625\n",
       "     Europe     68.539233   8365.486814\n",
       "     Oceania    71.085000  12696.452430\n",
       "1967 Africa     45.334538   2050.363801\n",
       "     Americas   60.410920   5668.253496\n",
       "     Asia       54.663640   5971.173374\n",
       "     Europe     69.737600  10143.823757\n",
       "     Oceania    71.310000  14495.021790\n",
       "1972 Africa     47.450942   2339.615674\n",
       "     Americas   62.394920   6491.334139\n",
       "     Asia       57.319269   8187.468699\n",
       "     Europe     70.775033  12479.575246\n",
       "     Oceania    71.910000  16417.333380\n",
       "1977 Africa     49.580423   2585.938508\n",
       "     Americas   64.391560   7352.007126\n",
       "     Asia       59.610556   7791.314020\n",
       "     Europe     71.937767  14283.979110\n",
       "     Oceania    72.855000  17283.957605\n",
       "1982 Africa     51.592865   2481.592960\n",
       "     Americas   66.228840   7506.737088\n",
       "     Asia       62.617939   7434.135157\n",
       "     Europe     72.806400  15617.896551\n",
       "     Oceania    74.290000  18554.709840\n",
       "1987 Africa     53.344788   2282.668991\n",
       "     Americas   68.090720   7793.400261\n",
       "     Asia       64.851182   7608.226508\n",
       "     Europe     73.642167  17214.310727\n",
       "     Oceania    75.320000  20448.040160\n",
       "1992 Africa     53.629577   2281.810333\n",
       "     Americas   69.568360   8044.934406\n",
       "     Asia       66.537212   8639.690248\n",
       "     Europe     74.440100  17061.568084\n",
       "     Oceania    76.945000  20894.045885\n",
       "1997 Africa     53.598269   2378.759555\n",
       "     Americas   71.150480   8889.300863\n",
       "     Asia       68.020515   9834.093295\n",
       "     Europe     75.505167  19076.781802\n",
       "     Oceania    78.190000  24024.175170\n",
       "2002 Africa     53.325231   2599.385159\n",
       "     Americas   72.422040   9287.677107\n",
       "     Asia       69.233879  10174.090397\n",
       "     Europe     76.700600  21711.732422\n",
       "     Oceania    79.740000  26938.778040\n",
       "2007 Africa     54.806038   3089.032605\n",
       "     Americas   73.608120  11003.031625\n",
       "     Asia       70.728485  12473.026870\n",
       "     Europe     77.648600  25054.481636\n",
       "     Oceania    80.719500  29810.188275"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df\\\n",
    "    .groupby(['year', 'continent'])[['lifeExp', 'gdpPercap']]\\\n",
    "    .mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>continent</th>\n",
       "      <th>lifeExp</th>\n",
       "      <th>gdpPercap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1952</td>\n",
       "      <td>Africa</td>\n",
       "      <td>39.135500</td>\n",
       "      <td>1252.572466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1952</td>\n",
       "      <td>Americas</td>\n",
       "      <td>53.279840</td>\n",
       "      <td>4079.062552</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1952</td>\n",
       "      <td>Asia</td>\n",
       "      <td>46.314394</td>\n",
       "      <td>5195.484004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1952</td>\n",
       "      <td>Europe</td>\n",
       "      <td>64.408500</td>\n",
       "      <td>5661.057435</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1952</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>69.255000</td>\n",
       "      <td>10298.085650</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1957</td>\n",
       "      <td>Africa</td>\n",
       "      <td>41.266346</td>\n",
       "      <td>1385.236062</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1957</td>\n",
       "      <td>Americas</td>\n",
       "      <td>55.960280</td>\n",
       "      <td>4616.043733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1957</td>\n",
       "      <td>Asia</td>\n",
       "      <td>49.318544</td>\n",
       "      <td>5787.732940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1957</td>\n",
       "      <td>Europe</td>\n",
       "      <td>66.703067</td>\n",
       "      <td>6963.012816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1957</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>70.295000</td>\n",
       "      <td>11598.522455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1962</td>\n",
       "      <td>Africa</td>\n",
       "      <td>43.319442</td>\n",
       "      <td>1598.078825</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1962</td>\n",
       "      <td>Americas</td>\n",
       "      <td>58.398760</td>\n",
       "      <td>4901.541870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1962</td>\n",
       "      <td>Asia</td>\n",
       "      <td>51.563223</td>\n",
       "      <td>5729.369625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1962</td>\n",
       "      <td>Europe</td>\n",
       "      <td>68.539233</td>\n",
       "      <td>8365.486814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1962</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>71.085000</td>\n",
       "      <td>12696.452430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1967</td>\n",
       "      <td>Africa</td>\n",
       "      <td>45.334538</td>\n",
       "      <td>2050.363801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1967</td>\n",
       "      <td>Americas</td>\n",
       "      <td>60.410920</td>\n",
       "      <td>5668.253496</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1967</td>\n",
       "      <td>Asia</td>\n",
       "      <td>54.663640</td>\n",
       "      <td>5971.173374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1967</td>\n",
       "      <td>Europe</td>\n",
       "      <td>69.737600</td>\n",
       "      <td>10143.823757</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1967</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>71.310000</td>\n",
       "      <td>14495.021790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1972</td>\n",
       "      <td>Africa</td>\n",
       "      <td>47.450942</td>\n",
       "      <td>2339.615674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1972</td>\n",
       "      <td>Americas</td>\n",
       "      <td>62.394920</td>\n",
       "      <td>6491.334139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1972</td>\n",
       "      <td>Asia</td>\n",
       "      <td>57.319269</td>\n",
       "      <td>8187.468699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1972</td>\n",
       "      <td>Europe</td>\n",
       "      <td>70.775033</td>\n",
       "      <td>12479.575246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1972</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>71.910000</td>\n",
       "      <td>16417.333380</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>1977</td>\n",
       "      <td>Africa</td>\n",
       "      <td>49.580423</td>\n",
       "      <td>2585.938508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1977</td>\n",
       "      <td>Americas</td>\n",
       "      <td>64.391560</td>\n",
       "      <td>7352.007126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1977</td>\n",
       "      <td>Asia</td>\n",
       "      <td>59.610556</td>\n",
       "      <td>7791.314020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1977</td>\n",
       "      <td>Europe</td>\n",
       "      <td>71.937767</td>\n",
       "      <td>14283.979110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1977</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>72.855000</td>\n",
       "      <td>17283.957605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>1982</td>\n",
       "      <td>Africa</td>\n",
       "      <td>51.592865</td>\n",
       "      <td>2481.592960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1982</td>\n",
       "      <td>Americas</td>\n",
       "      <td>66.228840</td>\n",
       "      <td>7506.737088</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>1982</td>\n",
       "      <td>Asia</td>\n",
       "      <td>62.617939</td>\n",
       "      <td>7434.135157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>1982</td>\n",
       "      <td>Europe</td>\n",
       "      <td>72.806400</td>\n",
       "      <td>15617.896551</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>1982</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>74.290000</td>\n",
       "      <td>18554.709840</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>53.344788</td>\n",
       "      <td>2282.668991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>68.090720</td>\n",
       "      <td>7793.400261</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>1987</td>\n",
       "      <td>Asia</td>\n",
       "      <td>64.851182</td>\n",
       "      <td>7608.226508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>73.642167</td>\n",
       "      <td>17214.310727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>1987</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>75.320000</td>\n",
       "      <td>20448.040160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>1992</td>\n",
       "      <td>Africa</td>\n",
       "      <td>53.629577</td>\n",
       "      <td>2281.810333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>1992</td>\n",
       "      <td>Americas</td>\n",
       "      <td>69.568360</td>\n",
       "      <td>8044.934406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>1992</td>\n",
       "      <td>Asia</td>\n",
       "      <td>66.537212</td>\n",
       "      <td>8639.690248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>1992</td>\n",
       "      <td>Europe</td>\n",
       "      <td>74.440100</td>\n",
       "      <td>17061.568084</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>1992</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>76.945000</td>\n",
       "      <td>20894.045885</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>1997</td>\n",
       "      <td>Africa</td>\n",
       "      <td>53.598269</td>\n",
       "      <td>2378.759555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>1997</td>\n",
       "      <td>Americas</td>\n",
       "      <td>71.150480</td>\n",
       "      <td>8889.300863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>1997</td>\n",
       "      <td>Asia</td>\n",
       "      <td>68.020515</td>\n",
       "      <td>9834.093295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>1997</td>\n",
       "      <td>Europe</td>\n",
       "      <td>75.505167</td>\n",
       "      <td>19076.781802</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>1997</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>78.190000</td>\n",
       "      <td>24024.175170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>2002</td>\n",
       "      <td>Africa</td>\n",
       "      <td>53.325231</td>\n",
       "      <td>2599.385159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>2002</td>\n",
       "      <td>Americas</td>\n",
       "      <td>72.422040</td>\n",
       "      <td>9287.677107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>2002</td>\n",
       "      <td>Asia</td>\n",
       "      <td>69.233879</td>\n",
       "      <td>10174.090397</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>2002</td>\n",
       "      <td>Europe</td>\n",
       "      <td>76.700600</td>\n",
       "      <td>21711.732422</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>2002</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>79.740000</td>\n",
       "      <td>26938.778040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>2007</td>\n",
       "      <td>Africa</td>\n",
       "      <td>54.806038</td>\n",
       "      <td>3089.032605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>2007</td>\n",
       "      <td>Americas</td>\n",
       "      <td>73.608120</td>\n",
       "      <td>11003.031625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>2007</td>\n",
       "      <td>Asia</td>\n",
       "      <td>70.728485</td>\n",
       "      <td>12473.026870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>2007</td>\n",
       "      <td>Europe</td>\n",
       "      <td>77.648600</td>\n",
       "      <td>25054.481636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>2007</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>80.719500</td>\n",
       "      <td>29810.188275</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    year continent    lifeExp     gdpPercap\n",
       "0   1952    Africa  39.135500   1252.572466\n",
       "1   1952  Americas  53.279840   4079.062552\n",
       "2   1952      Asia  46.314394   5195.484004\n",
       "3   1952    Europe  64.408500   5661.057435\n",
       "4   1952   Oceania  69.255000  10298.085650\n",
       "5   1957    Africa  41.266346   1385.236062\n",
       "6   1957  Americas  55.960280   4616.043733\n",
       "7   1957      Asia  49.318544   5787.732940\n",
       "8   1957    Europe  66.703067   6963.012816\n",
       "9   1957   Oceania  70.295000  11598.522455\n",
       "10  1962    Africa  43.319442   1598.078825\n",
       "11  1962  Americas  58.398760   4901.541870\n",
       "12  1962      Asia  51.563223   5729.369625\n",
       "13  1962    Europe  68.539233   8365.486814\n",
       "14  1962   Oceania  71.085000  12696.452430\n",
       "15  1967    Africa  45.334538   2050.363801\n",
       "16  1967  Americas  60.410920   5668.253496\n",
       "17  1967      Asia  54.663640   5971.173374\n",
       "18  1967    Europe  69.737600  10143.823757\n",
       "19  1967   Oceania  71.310000  14495.021790\n",
       "20  1972    Africa  47.450942   2339.615674\n",
       "21  1972  Americas  62.394920   6491.334139\n",
       "22  1972      Asia  57.319269   8187.468699\n",
       "23  1972    Europe  70.775033  12479.575246\n",
       "24  1972   Oceania  71.910000  16417.333380\n",
       "25  1977    Africa  49.580423   2585.938508\n",
       "26  1977  Americas  64.391560   7352.007126\n",
       "27  1977      Asia  59.610556   7791.314020\n",
       "28  1977    Europe  71.937767  14283.979110\n",
       "29  1977   Oceania  72.855000  17283.957605\n",
       "30  1982    Africa  51.592865   2481.592960\n",
       "31  1982  Americas  66.228840   7506.737088\n",
       "32  1982      Asia  62.617939   7434.135157\n",
       "33  1982    Europe  72.806400  15617.896551\n",
       "34  1982   Oceania  74.290000  18554.709840\n",
       "35  1987    Africa  53.344788   2282.668991\n",
       "36  1987  Americas  68.090720   7793.400261\n",
       "37  1987      Asia  64.851182   7608.226508\n",
       "38  1987    Europe  73.642167  17214.310727\n",
       "39  1987   Oceania  75.320000  20448.040160\n",
       "40  1992    Africa  53.629577   2281.810333\n",
       "41  1992  Americas  69.568360   8044.934406\n",
       "42  1992      Asia  66.537212   8639.690248\n",
       "43  1992    Europe  74.440100  17061.568084\n",
       "44  1992   Oceania  76.945000  20894.045885\n",
       "45  1997    Africa  53.598269   2378.759555\n",
       "46  1997  Americas  71.150480   8889.300863\n",
       "47  1997      Asia  68.020515   9834.093295\n",
       "48  1997    Europe  75.505167  19076.781802\n",
       "49  1997   Oceania  78.190000  24024.175170\n",
       "50  2002    Africa  53.325231   2599.385159\n",
       "51  2002  Americas  72.422040   9287.677107\n",
       "52  2002      Asia  69.233879  10174.090397\n",
       "53  2002    Europe  76.700600  21711.732422\n",
       "54  2002   Oceania  79.740000  26938.778040\n",
       "55  2007    Africa  54.806038   3089.032605\n",
       "56  2007  Americas  73.608120  11003.031625\n",
       "57  2007      Asia  70.728485  12473.026870\n",
       "58  2007    Europe  77.648600  25054.481636\n",
       "59  2007   Oceania  80.719500  29810.188275"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(df\n",
    "    .groupby(['year', 'continent'])[['lifeExp', 'gdpPercap']]\n",
    "    .mean()\n",
    "    .reset_index()\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEKCAYAAAAVaT4rAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl4lNXZx/HvDWHfd9kChF12iCwu\nKKCIoEWtuHQRRcW9aLUVW22pS9/6tm612orW5a2gKC3iUhXqUrQIsoUtgEDYQkJYQthDtvv9Yx5s\nxAQmIckkmd/nunJl5pnnDPdh4JcnZ86cY+6OiIhEjyqRLkBERMqWgl9EJMoo+EVEooyCX0Qkyij4\nRUSijIJfRCTKKPhFRKKMgl9EJMoo+EVEokxMpAsoSNOmTb19+/aRLkNEpMJYsmTJbndvFs65YQW/\nmTUEXgR6Ag5MAO4CuganNAQy3L1vAW03AweAXCDH3eNP9ue1b9+exYsXh1OaiIgAZrYl3HPDveJ/\nGvjQ3a8ws+pAbXe/Kt8f+Diw7wTth7n77nCLEhGR0nPS4Dez+sBQ4DoAd88CsvI9bsCVwPDSKVFE\nREpSOG/uxgG7gJfNbJmZvWhmdfI9fg6Q5u7rC2nvwBwzW2JmE0+xXhEROUXhDPXEAP2BO919oZk9\nDUwGHgwevwZ4/QTtz3L3FDNrDsw1s7XuPu/4k4IfChMBYmNjv/Mk2dnZJCcnk5mZGUbJlV/NmjVp\n06YN1apVi3QpIlLBhBP8yUCyuy8M7s8kFPyYWQxwOTCgsMbunhJ832lms4CBwHeC392nAlMB4uPj\nv7N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ZASQEX6MJzb77mNBvMR8DjYPzDXg26NtKID7f\nc00ANgRf10e6b+F+6ZO7IiJRRkM9IiJRRsEvIhJlFPwiIlFGwS8iEmUU/CIiUUbBLyISZRT8IqXA\nzKpGugaRwij4JeqZ2cPH1mQP7j9qZj8xs5+Z2aJgDfbf5Hv8bTNbEqzlPjHf8YNm9pCZLSS0RLFI\nuaTgFwl9fH88fLNMwdVAGtCZ0EJsfYEBZjY0OH+Cuw8g9GnVn5hZk+B4HULr2g9y9y/KsgMiRaFF\n2iTquftmM9tjZv2AFsAy4AxCa68sC06rS+gHwTxCYX9ZcLxtcHwPoZU6/16WtYsUh4JfJORF4Drg\nNELLD48A/sfdn89/UrDd4PnAEHc/bGafATWDhzPdPbesChYpLg31iITMIrR70hmEVlj8CJgQrNmO\nmbUOVq1sAOwNQr8boRU5RSoUXfGLAO6eZWafAhnBVfscM+sOfBnsG36Q0IqrHwK3mNkKQitVLohU\nzSLFpdU5RfjmTd2lwDh3Xx/pekRKk4Z6JOqZ2emE1lP/WKEv0UBX/CIiUUZX/CIiUUbBLyISZRT8\nIiJRRsEvIhJlFPwiIlFGwS8iEmX+H2f7LTixfvdaAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x24b82858f98>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "# probably don't need the magic anymore\n",
    "%matplotlib inline\n",
    "\n",
    "(df\n",
    "     .groupby(['year'])\n",
    "     [['lifeExp']]\n",
    "     .mean()\n",
    "     .plot()\n",
    ")\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
